import 'package:aio/aio.dart';

import '../wroks/contract_bean.dart';

// {
// "Id": "443",
// "manType": "跟单员",
// "payType": "70%提成",
// "beginDatetime": "2019/2/1 0:00:00",
// "endDatetime": "2019/2/28 0:00:00",
// "merchandiserSalesname": "陆清波",
// "amount1": "300000",
// "amount2": "900",
// "amount3": "32342.52",
// "amount4": "630",
// "createrName": "余建文",
// "createDateTime": "2019/3/21 15:41:32",
// "curStatus": "待审核",
// "currentWFId": "17894",
// "YwxId": "N6017-0",
// "YwxName": "提成审核（销售经理）",
// "page": "/GlassSales/percentagecheck2019.aspx"
// }
///提成审核列表数据
class PercentageCheckBean extends ContractCopyInfo {
  ///第二层：提成审核详情（客户名称，和项目名称）
  List<PercentageCheckInfoBean>? PercentageCheckInfo = null;

  @override
  fromJson(Map<String, dynamic> json) {
    // TODO: implement fromJson
    super.fromJson(json); //fixme 先实现父类的
    PercentageCheckInfo = setGenericFromJson(json, 'PercentageCheckInfo',
        <PercentageCheckInfoBean>[], PercentageCheckInfoBean());
  }

  @override
  instance() {
    // TODO: implement instance
    return PercentageCheckBean();
  }

  @override
  Map<String, dynamic> toJson() {
    // TODO: implement toJson
    var map = super.toJson(); //fixme 先实现父类的
    //var map = <String, dynamic>{};
    map["PercentageCheckInfo"] = PercentageCheckInfo;
    return map;
  }
}

///第二层：提成审核详情
class PercentageCheckInfoBean extends BaseBean {
  //客户名称
  String? customername = "";

  //项目名称
  String? contractname = "";

  //收款金额
  String cutamount = "";

  //提成比例（这是个百分数）
  String? payrate = "";

  //提成金额
  String? amount = "";

  //逾期扣除（这是个百分数）
  String? cutrate = "";

  //提成合计（100%）
  //下面三个都是根据提成金额amount衍生而来的，可以在app端进行计算。计算方式为payrate*cutamount，这里为了方便json使用，先进行了计算
  String? commissionTotal = "";

  //本次提成
  String? thisAmount = "";

  //提成结存
  String? commissionAmount = "";

  @override
  fromJson(Map<String, dynamic> json) {
    // TODO: implement fromJson
    customername = json['customername']?.toString() ?? "";
    contractname = json['contractname']?.toString() ?? "";
    cutamount = json['cutamount']?.toString() ?? "";
    payrate = json['payrate']?.toString() ?? "";
    amount = json['amount']?.toString() ?? "";
    cutrate = json['cutrate']?.toString() ?? "";
    commissionTotal = json['commissionTotal']?.toString() ?? "";
    thisAmount = json['thisAmount']?.toString() ?? "";
    commissionAmount = json['commissionAmount']?.toString() ?? "";
  }

  @override
  instance() {
    // TODO: implement instance
    return PercentageCheckInfoBean();
  }

  @override
  Map<String, dynamic> toJson() {
    // TODO: implement toJson
    var map = <String, dynamic>{};
    map["customername"] = customername;
    map["contractname"] = contractname;
    map["cutamount"] = cutamount;
    var payrate2 = NumUtil.strToDoubleStr(payrate); //提成比例
    map["payrate"] = payrate2;
    map["amount"] = amount;
    var cutrate2 = NumUtil.strToDoubleStr(cutrate);
    map["cutrate"] = cutrate2; //逾期扣除
    map["commissionTotal"] = commissionTotal;
    map["thisAmount"] = thisAmount;
    map["commissionAmount"] = commissionAmount;
    return map;
  }
}
